<?php
        	include "thuvien/db.php";
            include "thuvien/error.php";
?>

<?php
	

	

	
	if(isset($_REQUEST["MaSo"]))
	{
		$ma = $_REQUEST["MaSo"];
				
		$cnn = mysql_connect( $hostName, $username, $password );
		if ( ! $cnn )
			showError();
				 
		$dbselect = mysql_select_db( $databaseName);
		if(!$dbselect)
			showError();            
				
					
		$table = "hocsinh";
		$query = "Select * From $table where MaHS='$ma'";
		$result = mysql_query($query, $cnn);
		
		if (!$result)
		{
			showError(); 	
		}
		else
		{
			$numrow = mysql_num_rows($result);
			
			if($numrow>0)
			{
				echo "<table border='1'>";
					
					
					echo "<tr>";
						
						echo "<th>Mã HS</th>";
						echo "<th>Họ tên</th>";				
						echo "<th>Địa chỉ</th>";		
						echo "<th>Điện thoại</th>";
						echo "<th>Ngày sinh</th>";

					echo "</tr>";
					
					

											
					while ($row = mysql_fetch_row($result))
					{
						$mahs = $row[0];
						$hoten= $row[1];
						$diachi = $row[2];
						$dienthoai = $row[3];
						$ngaysinh = $row[4];

						echo "<tr>";
							
							echo "<td><input type='text' id='$mahs ma' value='$mahs' readonly class=\"cell\" /></td>";
							echo "<td><input type='text' id='$mahs ten' value='$hoten' class=\"cell\" /></td>";
							echo "<td><input type='text' id='$mahs diachi' value='$diachi' class=\"cell\"/></td>";
							echo "<td><input type='text' id='$mahs dienthoai' value='$dienthoai' class=\"cell\"/></td>";
							echo "<td><input type='text' id='$mahs ngaysinh' value='$ngaysinh' class=\"cell\"/></td>";
					
						
						echo "</tr>";			
					}
					
					echo "<tr>";
							
							
							echo "<td>";
							echo "<input type='button' name='MaHS' value='Delete' onClick='XoaChiTiet($mahs)'/>";
							echo "</td>";
							
							echo "<td>";
							echo "<input type='button' name='MaHS' value='Update' onClick='capnhatchitiet($mahs)'/>";
							echo "</td>";

						echo "</tr>";
					
					
					echo "</table>";
				}
			
			}
					
					
							
			mysql_close( $cnn );
		
	}
						
?>